﻿using MediatorPattern.Character;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MediatorPattern.Mediator;

/// <summary>
/// 中介者模式，相当于一个QQ群，在这里发消息大家都能收到
/// </summary>
internal class BaseMediator
{
    private List<BaseCharacter> _characterList = new();
    public void AddCharacter(BaseCharacter character)
    {
        _characterList.Add(character);
    }

    public void SendMessage(string message, BaseCharacter characterFrom)
    {
        Console.WriteLine($"{characterFrom.Name} Send:{message}");
        foreach (BaseCharacter character in _characterList)
        {
            character.GetMessage(message, characterFrom);
        }
    }
}
 